package com.lxg.ai.tool;

import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.web.search.WebSearchTool;

import java.lang.reflect.Method;


/**
 * 谷歌webSearchApi
 */
public class MyWebSearchFactoryTool {

    public static Method getMethod(WebSearchTool webSearchTool) {
        Method webSearchMethod = null;
        try {
            webSearchMethod = webSearchTool.getClass().getMethod("searchWeb", String.class);
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }
        if (!webSearchMethod.isAnnotationPresent(Tool.class)) {
            throw new RuntimeException("SearchAPiGoogleWebSearchTool" + "的" + webSearchMethod.getName() + "没有被@tool注解");
        }
        return webSearchMethod;
//                toolSpecificationFrom(webSearchMethod);
//        defaultToolExecutor = new DefaultToolExecutor(webSearchTool, webSearchMethod);
    }
}
